package cn.by.wms.enums;

import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Optional;

public enum InvetoryOptionType {

    IN(1,"入库"),
    SALE_OUT(10,"销售出库"),
    TRANSFER_OUTBOUND(20,"调拨出库"),
    DAMAGED_OUTBOUND(30,"破损出库");

    @Getter @Setter
    private int code;
    @Getter @Setter
    private String message;

    InvetoryOptionType(int code , String message){
        this.code = code;
        this.message = message;
    }

    public static InvetoryOptionType getByCode(int code){

        InvetoryOptionType[] values = InvetoryOptionType.values();
        // jdk1.8   stream流的操作
        // jdk1.8   Optional
        Optional<InvetoryOptionType> first = Arrays.stream(values).filter(item -> item.code == code).findFirst();
        return first.orElse(null);

    }
}
